{include file="common/top" /}
<div style="padding: 20px;background: #ffffff;" >
	<form class="layui-form " action="" >
        <div class="layui-tab" id="test1" lay-filter="test1">
            <ul class="layui-tab-title">
              <li class="layui-this" lay-id="1" >基础信息</li>
              <li lay-id="2">投放页面</li>
              <li lay-id="3">视频</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">客户：</label>
                        <div class="layui-col-xs4">
                            <select name="customer_id"  lay-search=""  autocomplete="off">
                                <option value="">直接选择或搜索选择</option>
                                {volist name="cu_list" id='cu'}
                                    <option value="{$cu.id}" {eq name="rs.customer_id" value="$cu.id"}selected{/eq}>{$cu.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">投放链接：</label>
                        <div class="layui-col-xs4">
                            <input type="text" name="putin_url" value="{$rs.putin_url}"  autocomplete="off" placeholder="请输入投放链接" class="layui-input puturl">
                        </div>
                        <label class="layui-form-label">预计时间：</label>
                        <div class="layui-col-xs4">
                            <input name="scheduled_time" id="wc_time" value="{$rs.scheduled_time}"   autocomplete="off" placeholder="YYYY-mm-dd" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux"> &nbsp预计备户完成时间</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">CNZZ链接：</label>
                        <div class="layui-col-xs4">
                            <input type="text" name="cnzz_url" value="{$rs.cnzz_url}"  autocomplete="off" placeholder="请输入CNZZ链接" class="layui-input">
                        </div>
                        <label class="layui-form-label">CNZZ密码：</label>
                        <div class="layui-col-xs4">
                            <input type="text" name="cnzz_password" value="{$rs.cnzz_password}"  autocomplete="off" placeholder="请输入CNZZ密码" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="    width: 10%;">客户诉求目标：</label>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">跑消耗：</label>
                        <div class="layui-col-xs4">
                            <input type="number" name="consume_goal" value="{$rs.consume_goal}"  autocomplete="off" placeholder="请输入" class="layui-input">
                        </div>
                        <label class="layui-form-label">跑表单：</label>
                        <div class="layui-col-xs4">
                            <input type="number" name="form_goal" value="{$rs.form_goal}"  autocomplete="off" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注：</label>
                        <div class="layui-col-xs10">
                            <textarea name="note" autocomplete="off" placeholder="请输入详细的备注" class="layui-textarea">{$rs.note}</textarea>
                        </div>
                    </div>
                    <hr />
                </div>
                <div class="layui-tab-item">
                    <div class="layui-row layui-col-space15">
                        <div class="layui-col-md6">
                            <div class="layui-card">
                                <div class="layui-card-header">审核页</div>
                                <div class="layui-card-body">
                                    <iframe id='shye' src='{$rs.putin_url}' frameborder='0' align='left' width='70%' class='pull-left' height='500' ><p>你的浏览器不支持iframe标签</p></iframe>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-card">
                                <div class="layui-card-header">投放页</div>
                                <div class="layui-card-body">
                                    <iframe id='tfye' src='{:$rs["putin_url"]?$rs["putin_url"]."/?mtNB":''}' frameborder='0' align='left' width='70%' class='pull-left' height='500' ><p>你的浏览器不支持iframe标签</p></iframe>
                                </div>
                            </div>
                        </div>
                    </div> 
                <hr />
                </div>
                <div class="layui-tab-item ">
                    <div class=" layui-row sp">
                        {empty name="rs.video_url"}
                            <div class="layui-col-md12 " >
                                <div class="layui-card">
                                    <div class="layui-card-header">视频</div>
                                    <div class="layui-card-body">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">视频链接：</label>
                                            <div class="layui-col-xs4">
                                                <input type="text" name="video_url[]"   autocomplete="off" placeholder="请输入视频链接" class="layui-input video">
                                            </div>
                                            <label class="layui-form-label">封面链接：</label>
                                            <div class="layui-col-xs4">
                                                <input type="text" name="cover_url[]"   autocomplete="off" placeholder="请输入封面链接" class="layui-input cover">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label"></label>
                                            <div class="layui-col-xs4">
                                                <video class="my_video" width="40%"  controls="controls" autobuffer="autobuffer" loop="loop">
                                                    <source class='vs' src="#" type="video/mp4"></source>
                                                </video>
                                            </div>
                                            <label class="layui-form-label"></label>
                                            <div class="layui-col-xs4">
                                                <img width="40%" class='cs' src="#">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {else /}
                            {volist name="rs.video_url" id="vo" key="k" }
                                <div class="layui-col-md12" >
                                    <div class="layui-card">
                                        <div class="layui-card-header">视频
                                            {gt name="k" value="1"}
                                                &nbsp&nbsp <a  class="layui-btn del_sp  layui-btn-xs layui-btn-danger" >删除</a >
                                            {/gt}
                                        </div>
                                        <div class="layui-card-body">
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">视频链接：</label>
                                                <div class="layui-col-xs4">
                                                    <input type="text" name="video_url[]" value="{$vo}"  autocomplete="off" placeholder="请输入视频链接" class="layui-input video">
                                                </div>
                                                <label class="layui-form-label">封面链接：</label>
                                                <div class="layui-col-xs4">
                                                    <input type="text" name="cover_url[]" value="{$rs['cover_url'][$k-1]}"  autocomplete="off" placeholder="请输入封面链接" class="layui-input cover">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label"></label>
                                                <div class="layui-col-xs4">
                                                    <video class="my_video" width="40%"  controls="controls" autobuffer="autobuffer" loop="loop">
                                                        <source class='vs' src="{$vo}" type="video/mp4"></source>
                                                    </video>
                                                </div>
                                                <label class="layui-form-label"></label>
                                                <div class="layui-col-xs4">
                                                    <img width="40%" class='cs' src="{$rs['cover_url'][$k-1]}">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            {/volist}
                        {/empty}
                    </div>
                    
                    <hr />
                    <div class="layui-form-item">
                        <div class="layui-col-xs12">
                            {empty name="rs"}
                                <input type="hidden" name="pid" value="{$Request.get.id}"  >
                            {else /}
                                <input type="hidden" name="id" value="{$rs.id}"  >
                            {/empty}
                            <button class="layui-btn"  lay-submit="" lay-filter="demo1">提交</button>
                            <a  class="layui-btn add_sp" >添加视频</a >
                        </div>
                    </div>
                </div>
            </div>
        </div>
	</form>
    <div class="layui-form-item but ">
        <div class="layui-col-xs12">
            <button class="layui-btn next " >下一步</button>
        </div>
    </div>
    <div style="display: none;" id="muban">
        <div class="layui-col-md12" >
            <div class="layui-card">
                <div class="layui-card-header">视频&nbsp&nbsp
                    <a  class="layui-btn del_sp  layui-btn-xs layui-btn-danger" >删除</a >
                </div>
                <div class="layui-card-body">
                    <div class="layui-form-item">
                        <label class="layui-form-label">视频链接：</label>
                        <div class="layui-col-xs4">
                            <input type="text" name="video_url[]"   autocomplete="off" placeholder="请输入视频链接" class="layui-input video">
                        </div>
                        <label class="layui-form-label">封面链接：</label>
                        <div class="layui-col-xs4">
                            <input type="text" name="cover_url[]"   autocomplete="off" placeholder="请输入封面链接" class="layui-input cover">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-col-xs4">
                            <video class="my_video" width="40%"  controls="controls" autobuffer="autobuffer" loop="loop">
                                <source class='vs' src="#" type="video/mp4"></source>
                            </video>
                        </div>
                        <label class="layui-form-label"></label>
                        <div class="layui-col-xs4">
                            <img width="40%" class='cs' src="#">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="common/footer" /}
<script>
	layui.use(['form', 'layedit', 'laydate','element'], function(){
        var form = layui.form ,layer = layui.layer,laydate = layui.laydate,element = layui.element;
        var n= 1;
        laydate.render({
            elem: '#wc_time'
        });
        element.on('tab(test1)', function(data){
            n = data.index + 1;
            if(n != 3){
                $('.but').css('display','');
            }else{
                $('.but').css('display','none');
            }
        });
        $('.next').click(function(){
            n = n + 1;
            if(n == 3){
                $('.but').css('display','none');
            }
            element.tabChange('test1', n);
        });
        
		  //监听提交
		  form.on('submit(demo1)', function(data){
			var articleFrom = data.field;
			layer.load(1, { shade : [ 0.5, '#676a6c' ] });
			$.post("{:url('acc_info')}?t=json",articleFrom,function(data){
				layer.closeAll();
				if (data['code'] == 1) {
                    layer.msg(data['msg'], { icon : 6 ,time: 2000},function(){
                        window.location.reload();
                    });
                    
				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
			
			return false;
		  });
		  
		});
        //添加视频模块
        $(document).on('click', '.add_sp', function() {
            console.log('添加视频模块');
            var v = $('#muban').html();
            $('.sp').append(v);
        })
        //删除视频模块
        $(document).on('click', '.del_sp', function() {
            var v = $(this).parent().parent().parent().remove() 
        })
        //把视频添加到播放器
        $(document).on('blur', '.video', function() {
            var v = $(this).val();
            $(this).parent().parent().next().find('.my_video').attr('src',v);
            //$(this).parent().parent().next().find('.my_video').play(); 
        })
        //把图片地址添加到img
        $(document).on('blur', '.cover', function() {
            var v = $(this).val();
            $(this).parent().parent().next().find('.cs').attr('src',v);
        })
        //添加投放地址
        $(document).on('blur', '.puturl', function() {
            var v = $(this).val();
            $('#shye').attr('src',v);
            $('#tfye').attr('src',v+'/?mtNBa');
        })
</script>
